<?php
/**
  * @version $Id: klearkache.php, v0.16 2007/12/16 11:55:55 visualweb Exp $ 
  * @package com_mojo
  * @copyright (c) 1guywebdesign.com 
  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL 
  */
  //TODO: use built-in cache?
if (!defined('ABSPATH')) {
	define( '_VALID_MOS', 1 );

	include_once( '../../../globals.php' );
	require_once( '../../../configuration.php' );
	require_once( '../../../includes/joomla.php' );

	global $mosConfig_absolute_path, $mosConfig_live_site, $database;

	$mainframe = new mosMainFrame( $database, isset($option), '.' );
	$mainframe->initSession();
	$my = $mainframe->getUser();

	$user=null;
	if ($my->id) {
	$query = "SELECT *"
	. "\n FROM #__users"
	. "\n WHERE id = ". intval( $my->id )
	;
	$database->setQuery( $query );
	$database->loadObject($user);
	}
	$database->setQuery("SELECT id FROM #__menu WHERE link='index.php?option=com_mojo' AND published='1'");
    $Itemid = $database->loadResult();
    require_once($mosConfig_absolute_path.'/components/com_mojo/wp-config.php');
    
}
define('WP_INSTALLING', true);
timer_start();
require_once(ABSPATH . '/wp-admin/upgrade-functions.php');

$step = $_GET['step'];
if (!$step) $step = 0;
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<style media="screen" type="text/css">
	<!--
	html {
		background: #fff;
	}
	body {
		background: #fff;
		color: #000;
		font-family: Tahoma, Trebuchet, Verdana, Arial, sans-serif;
		margin-left: 20%;
		margin-right: 20%;
		padding: .2em 2em;
	}
	
	h1 {
		color: #006;
		font-size: 18px;
		font-weight: lighter;
	}
	
	h2 {
		font-size: 16px;
	}
	
	p, li, dt {
		line-height: 140%;
		padding-bottom: 2px;
	}

	ul, ol {
		padding: 5px 5px 5px 20px;
	}
	#logo {
		margin-bottom: 2em;
	}
.step a, .step input {
	color:#bce27f;
	font-size: 1em;
}
.step, th {
	text-align: right;
}
#footer {
text-align: center; border-top: 1px solid #ccc; padding-top: 1em; font-style: italic;
}
	-->
	</style>
</head>
<body>
<h1 id="logo"><img alt="Mojo" src="images/mojoflush.gif" />&nbsp; Delete mojoBlog Cached files...</h1>
<?php
switch($step) {

	case 0:
?> 
<p>You are about to flush/delete/wax/destroy all previously cached mojo posts and preferences.</p>
<p>You -might- want to do this <strong>IF</strong> you've gotten that scary message: <em>Your database is out of date, you need to upgrade.</em></p>
<p>Even if you haven't gotten that message, it's a good idea and great blog hygiene to clear older cached files every so often so that Search Engines can find the freshest content from your blog.</p>
<p>Clearing your cache will <strong>not</strong> affect your existing posts, pages, or other relevant mojostuff so, it's safe to proceed.</p> 

<h2 class="step"><a href="klearkache.php?step=1"><?php _e('Delete older mojoBlog cache files &raquo;'); ?></a></h2>
<?php
	break;
	
	case 1:
	wp_cache_flush();
// ADD HOOKS for imminent mojoBlog upgrade -kdm 12/2007
//	make_db_current_silent();
//	upgrade_all();
//	wp_cache_flush();
?> 
<h2><?php _e('Step 1'); ?></h2> 
	<p><?php printf(__("You got sparkling FRESH mojo!. all done... <a href='%s'>Have fun</a>!"), $mosConfig_live_site . '/components/com_mojo/wp-admin/index.php'); ?></p>

<div id="klearkache_results">
<pre>
<?php printf(__('%s cached files waxed'), $wpdb->num_queries); ?>

<?php printf(__('in under %s seconds'), timer_stop(0)); ?>
</pre>
</div><!--[END] output of dump results-->

<?php
	break;
}
?> 
</body>
</html>
